﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Html
{
    public class PropertyPath : IEnumerable<string>
    {
        private string[] pathes;
        public PropertyPath(string path)
        {
            pathes = path.Split('.');
        }
        public int Count { get { return pathes.Length; } }
        public override string ToString()
        {
            return String.Join(",", pathes);
        }


        public static implicit operator PropertyPath(string pp)
        {
            return new PropertyPath(pp);
        }
        public static implicit operator string(PropertyPath pp)
        {
            return pp.ToString();
        }
        public IEnumerator<string> GetEnumerator()
        {
            foreach (var item in pathes)
            {
                yield return item;
            }
            yield break;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return pathes.GetEnumerator();
        }
    }
}
